package com.itheima.array;

import com.itheima.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayListDemo05 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        /*Student stu1 = getStudent();
        Student stu2 = getStudent();
        Student stu3 = getStudent();*/
        list.add(getStudent());
        list.add(getStudent());
        list.add(getStudent());
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i).getName() + "  " + list.get(i).getAge());
        }
    }

    public static Student getStudent() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生姓名:");
        String name = sc.next();
        System.out.println("请输入学生年龄:");
        int age = sc.nextInt();
        Student stu = new Student(null,name, age,0);
        return stu;
    }
}
